package com.example.quartz.project.job;

import com.example.quartz.project.service.QuartzService;
import lombok.extern.slf4j.Slf4j;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.Date;

/**
 * @author 打小就爱笑捏
 * @date 2019/11/11
 */
@Component
@Slf4j
public class JobTwo implements Job {
    private static Integer sum = 1;

    @Resource
    private QuartzService quartzService;
    private String parameter;/*参数*/

    public void setParameter(String parameter) {
        this.parameter = parameter;
    }

    @Override
    public void execute(JobExecutionContext jobExecutionContext) {
        quartzService.test(this.parameter, sum);
        System.out.println("执行定时任务第" + sum + "次!参数是-----------" + this.parameter + "-----------" + new Date());
        sum++;
    }
}
